package com.czxy.changgou3.com.czxy.changgou3.controller;

import com.czxy.changgou3.com.czxy.changgou3.service.BrandService;
import com.czxy.changgou3.pojo.Brand;
import com.czxy.vo.BaseResult;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zhangmengxiang1@itcast.cn
 * @version 1.0
 * @date 2020/4/22
 */
@RestController
@RequestMapping("/brands")
public class BrandController {

    @Resource
    private BrandService brandService;

    /**
     * 接口规范： /cgwebservice/brands/category/76
     * @param categoryId
     * @return
     */
    @GetMapping("/category/{categoryId}")
    public BaseResult findAll(@PathVariable("categoryId") Integer categoryId){
        //查询
        List<Brand> list = brandService.findAll(categoryId);
        //封装
        return BaseResult.ok("查询成功", list);
    }
}
